#include<sys/time.h>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>

#include <vector>
using namespace std;

// the port client will be connecting to
#define PORT_CONFIG 	49251
#define PORT_DATATRANSF 49250
// max number of bytes we can get at once
#define MAXDATASIZE 300
#define MAXHOSTNAME 80

class DataTransportConfig {

public:
  DataTransportConfig();
  ~DataTransportConfig();
  void Configure();
  void error(char*);
  void GetProduserHostInfo();
  void ClientConfigSocketRun();
  void ClientDatatransportSocketRun();

  unsigned char *ReadConfigSocket_data(int datalength);
  unsigned char *ReadClientConfigSocket(const char string[4]);
  unsigned int ReadConfigSocket_length(const char string[4]);

  //unsigned char *ReadDataTransportSocket_data(int datalength);
  //std::vector<unsigned char> ReadDataTransportSocket_data(int datalength);
  unsigned int ReadDataTransportSocket_length(const char string[4]);
  char *ReadDataTransportSocket_data(int datalength);
  //void ReadDataTransportSocket_data(int datalength);



  void SendClientConfigSocket(const char *text);

private:
	struct hostent *hclient, *hconfig, *hdatatransport;
	struct sockaddr_in client;
	struct sockaddr_in config;
	struct sockaddr_in datatransport;

	struct timeval tv;
	unsigned int sec;
	unsigned int microsec;

	char ThisHost[80];

	char Buffer_data[7000];
	char Buffer_length[7000];
	unsigned long data;// = INADDR_NONE;
	unsigned long data_trans_addres;// = INADDR_NONE;
	int sock_config;
	int sock_datatransport;
	int numbytes;

};
